package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Ticket extends BaseDomain{
    //封面图片
    private String coverUrl;
    //景点名
    private String name;
    //景点所在地址
    private String address;
    //价格
    private Double price;
    //景点级别
    private String grade;
    //关联地区
    private Region region;
    //折扣
    private Double cutoff;
    //景点介绍
    private  String intro;
    //门票时间
    @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date time;

    //json字符串
    public String getJsonString(){
        Map<String,Object> map=new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("coverUrl",coverUrl);
        if (region!=null){
            map.put("regionId",region.getId());
        }
        map.put("grade",grade);
        map.put("cutoff",cutoff);
        map.put("intro",intro);
        map.put("price",price);
        return JSONUtils.toJSONString(map);
    }

}